package io.github.jhipster.sample.domain;

import static io.github.jhipster.sample.domain.AssertUtils.bigDecimalCompareTo;
import static org.assertj.core.api.Assertions.assertThat;

public class OperationAsserts {

    /**
     * Asserts that the entity has all properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertOperationAllPropertiesEquals(Operation expected, Operation actual) {
        assertOperationAutoGeneratedPropertiesEquals(expected, actual);
        assertOperationAllUpdatablePropertiesEquals(expected, actual);
    }

    /**
     * Asserts that the entity has all updatable properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertOperationAllUpdatablePropertiesEquals(Operation expected, Operation actual) {
        assertOperationUpdatableFieldsEquals(expected, actual);
        assertOperationUpdatableRelationshipsEquals(expected, actual);
    }

    /**
     * Asserts that the entity has all the auto generated properties (fields/relationships) set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertOperationAutoGeneratedPropertiesEquals(Operation expected, Operation actual) {
        assertThat(actual)
            .as("Verify Operation auto generated properties")
            .satisfies(a -> assertThat(a.getId()).as("check id").isEqualTo(expected.getId()));
    }

    /**
     * Asserts that the entity has all the updatable fields set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertOperationUpdatableFieldsEquals(Operation expected, Operation actual) {
        assertThat(actual)
            .as("Verify Operation relevant properties")
            .satisfies(a -> assertThat(a.getDate()).as("check date").isEqualTo(expected.getDate()))
            .satisfies(a -> assertThat(a.getDescription()).as("check description").isEqualTo(expected.getDescription()))
            .satisfies(a ->
                assertThat(a.getAmount()).as("check amount").usingComparator(bigDecimalCompareTo).isEqualTo(expected.getAmount())
            );
    }

    /**
     * Asserts that the entity has all the updatable relationships set.
     *
     * @param expected the expected entity
     * @param actual the actual entity
     */
    public static void assertOperationUpdatableRelationshipsEquals(Operation expected, Operation actual) {
        assertThat(actual)
            .as("Verify Operation relationships")
            .satisfies(a -> assertThat(a.getBankAccount()).as("check bankAccount").isEqualTo(expected.getBankAccount()))
            .satisfies(a -> assertThat(a.getLabels()).as("check labels").isEqualTo(expected.getLabels()));
    }
}
